package com.speed_run.controller;

import com.speed_run.service.UserService;
import com.speed_run.utils.ResponseEntity;
import com.speed_run.vo.NameAndPassWord;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 
 * @author wafer
 *
 */
@Controller
@RequestMapping("/v1/api")
@Log4j2
public class LoginController {
	
	@Resource
	private UserService userService;
	
	@GetMapping
	public String login(){
		return "index";
	}
	

	@PostMapping("/login")
	@ResponseBody
	public ResponseEntity userLogin(@Valid @RequestBody  NameAndPassWord auth){
		return userService.auth(auth);
	}

	/**
	 * 退出操作
	 * @return
	 */
	@DeleteMapping()
	public ResponseEntity useLogout(){
		return ResponseEntity.ok("退出成功");
	}
}
